<?php
namespace app\index\controller;
use module\InsurerApi;
use library\Validator;
use library\AliOss;
use library\Alisms;
use OSS\OssClient;
use module\UploadApi;
use think\Db;
class Index extends CommonController
{
    protected $_require_login = true;
    public function index()
    {
        echo $this->uid;
        //阿里云上传测试demo
       // $avator = $this->request->file('avatar');
       //  $e= AliOss::upload($avator);
     //  return $this->response->api(['url'=>$e['info']['url']],self::SUCCESS_CODE,'上传成功');

    }

    /**
     * 获取省
     */
    public function getOmit(){
        $whereprovince['top_parentid'] = 0;
        $listprovince = Db::table('egion')->field('region_id,region_name')->where($whereprovince)->select();
        return $this->response->api(['province_list'=>$listprovince]);
    }
    /**
     * 市
     */
    public function getCitys(){
        list($region_id) = Validator::make($this->request->request(), [
            'region_id' => 'required',
        ]);
        $where['top_parentid'] =$region_id;
        $where['level'] = 2;
        $list = Db::table('egion')->field('region_id,region_name')->where($where)->select();
        return $this->response->api(['citys_list'=>$list]);
    }
    /**
     *获取地级县
     */
    public function getDistrict(){
        list($region_id) = Validator::make($this->request->request(), [
            'region_id' => 'required',
        ]);
        $where['parent_id'] = $region_id;
        $where['level'] = 3;
        $list = Db::table('egion')->field('region_id,region_name')->where($where)->select();
        return $this->response->api(['district_list'=>$list]);
    }
    /**
     *获取保险种类列表
     */
    public function getInsuranceType(){
        $list = Db::table('insurance_type')->field('it_id,it_name')->where('deleted',0)->select();
        return $this->response->api(['type_list'=>$list]);
    }

    /**
     *获取代录人类型
     */
    public function recorderType(){
        $list = Db::table('recorder_type')->field('id,name')->select();
        return $this->response->api(['type_list'=>$list]);
    }
    /**
     *获取商品类型
     */
    public function goodsType(){
        $list = Db::table('goods_type')->field('gt_id,gt_name')->where('deleted',0)->select();
        return $this->response->api(['type_list'=>$list]);
    }
}
